﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Gol.Domain;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Test.Gol.Domain.GameOfLife
{
    [TestClass]
    public class BasicTests
    {
        [TestMethod]
        public void WhenNextingThenNewGridShouldExist()
        {
            int rows = 10;
            int cols = 10;
            global::Gol.Domain.GameOfLife gameOfLife = new global::Gol.Domain.GameOfLife(rows, cols);
            gameOfLife.Start(new int[,] { { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 0, 5 }, { 0, 6 }, { 0, 7 }, { 0, 8 }, { 0, 9 } });


            gameOfLife.NextGeneration();
            Assert.IsFalse(gameOfLife.CellGrid[0, 0].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[0, 1].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[0, 2].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[0, 3].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[0, 4].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[0, 5].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[0, 6].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[0, 7].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[0, 8].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[0, 9].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[1, 0].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[1, 1].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[1, 2].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[1, 3].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[1, 4].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[1, 5].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[1, 6].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[1, 7].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[1, 8].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[1, 9].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[0, 9].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 0].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 1].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 2].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 3].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 4].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 5].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 6].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 7].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 8].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 9].IsAlive);

        }


        [TestMethod]
        public void WhenStartingThenNewGridShouldExist()
        {
            int rows = 10;
            int cols = 10;
            global::Gol.Domain.GameOfLife gameOfLife = new global::Gol.Domain.GameOfLife(rows, cols);
            gameOfLife.Start(new int[,] { { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 0, 5 }, { 0, 6 }, { 0, 7 }, { 0, 8 }, { 0, 9 } });


            gameOfLife.NextGeneration();
            Assert.IsFalse(gameOfLife.CellGrid[0, 0].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[0, 1].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[0, 2].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[0, 3].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[0, 4].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[0, 5].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[0, 6].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[0, 7].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[0, 8].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[0, 9].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[1, 0].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[1, 1].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[1, 2].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[1, 3].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[1, 4].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[1, 5].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[1, 6].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[1, 7].IsAlive);
            Assert.IsTrue(gameOfLife.CellGrid[1, 8].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[1, 9].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[0, 9].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 0].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 1].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 2].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 3].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 4].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 5].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 6].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 7].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 8].IsAlive);
            Assert.IsFalse(gameOfLife.CellGrid[2, 9].IsAlive);

        }
    }
}
